const getUserMedia = (constrains) => {
  if (window.navigator.mediaDevices.getUserMedia) {
    console.log('window.navigator.mediaDevices.getUserMedia')
    return window.navigator.mediaDevices.getUserMedia(constrains)
  } else if (window.navigator.webkitGetUserMedia) {
    console.log('window.navigator.webkitGetUserMedia')
    return window.navigator.webkitGetUserMedia(constrains)
  } else if (window.navigator.mozGetUserMedia) {
    console.log('window.navigator.mozGetUserMedia')
    return window.navigator.mozGetUserMedia(constrains)
  } else if (window.navigator.getUserMedia) {
    console.log('window.navigator.getUserMedia')
    return window.navigator.getUserMedia(constrains)
  }
  throw new Error('unable to get user media')
}

export { getUserMedia }
